Basic Commands
The SDK commands below are designed to conduct basic SDK operations:
Set API domain
Sets the SDK to use your back-end's domain name. Please head to https://app.vpnwholesaler.com/credentials in order to retrieve your API base domain name.
Important Please use the domain name only without scheme (i.e. do not include https://)
Login required: No
CmdProc Code: OVS_CMD_SET_API_DOMAIN
Command number: 9
Input:
{
"api_domain": "your_subdomain.vpngn.com",
"csid": "your_client_side_api_key"
}
Response: OVS_NOTIFY_SET_API_DOMAIN
OVS_NOTIFY_SET_API_DOMAIN Successful response OVS_ERR_OK data is null
Code sample:
C++
void SetAPIDomain(const char* api_domain, const char* client_api_key)
{
json j_obj, j_data_obj;
char szCmd[1024];
j_obj["cmd"] = OVS_CMD_SET_API_DOMAIN;
j_data_obj["api_domain"] = api_domain;
j_data_obj["csid"] = client_api_key;
j_obj["data"] = j_data_obj;
snprintf(szCmd, sizeof(szCmd), "%s", j_obj.dump().c_str());
CmdProc(szCmd);
}
Set Logger Mode
Enable or disable log file creation. Logging is enabled by default.
Login required: No
CmdProc Code: OVS_CMD_SET_LOGGING
Command number: 26
Input:
{
"status": true | false
}
Response: OVS_NOTIFY_SET_LOGGING
OVS_NOTIFY_SET_LOGGING Successful response OVS_ERR_OK data is null
OVS_NOTIFY_SET_LOGGING Failed response OVS_ERR_MISSING_PARAMS data is null
Code sample:
C++
void SetLogging(bool status)
{
json j_obj, j_data_obj;
char szCmd[1024];
j_obj["cmd"] = OVS_CMD_SET_LOGGING;
j_data_obj["status"] = status;
j_obj["data"] = j_data_obj;
snprintf(szCmd, sizeof(szCmd), "%s", j_obj.dump().c_str());
CmdProc(szCmd);
}
Login
Logins to the back-end and retrieves active products associated with the given user.
Login required: No
CmdProc Code: OVS_CMD_LOGIN
Command number: 1
Input:
Username and Pasword
{
"username": "end_user_email_address",
"password": "end_user_password"
}
end_user_email_address - End-user's username
end_user_password - End-user's password
Short token
{
"username": "$$short_token$$",
"password": "user_short_token"
}
user_short_token - End user's short token
Response: OVS_NOTIFY_LOGIN
OVS_NOTIFY_LOGIN Successful response OVS_ERR_OK
Data contains information about user account and account status:
- nextduedate - Plan renewal date
- username - OpenVPN username
- password - OpenVPN password
- status - Account status
- name - User's first name
- email - User's email address
- debug - Debug mode?
- free - Free plan?
OVS_NOTIFY_LOGIN Failed response
- OVS_ERR_WEB_API
- OVS_ERR_RESP_INVALID
- OVS_ERR_LOGIN_FAILED
- OVS_ERR_NO_ACTIVE_PLAN - after receiving this response it is still possible to use user management functions. However, VPN functions are unavailable until the end-user is logged-in with an active plan (it is recommended to invoke Logout method before logging-in). data contains a human readable error description
Code sample:
C++
void Login(const char* username, const char* password)
{
json j_obj, j_data_obj;
char szCmd[1024];
j_obj["cmd"] = OVS_CMD_LOGIN;
j_data_obj["username"] = username;
j_data_obj["password"] = password;
j_obj["data"] = j_data_obj;
snprintf(szCmd, sizeof(szCmd), "%s", j_obj.dump().c_str());
CmdProc(szCmd);
}
Logout
Logs out a currently logged-in end-user.
Login required: Yes
CmdProc Code: OVS_CMD_LOGOUT
Command number: 38
Input: Not required
Response: OVS_NOTIFY_LOGOUT
OVS_NOTIFY_LOGOUT Successful response OVS_ERR_OK data is null
OVS_NOTIFY_LOGOUT Failed response OVS_ERR_LOGOUT data contains a human readable error description
Code sample:
C++
void Logout()
{
json j_obj;
char szCmd[1024];
j_obj["cmd"] = OVS_CMD_LOGOUT;
snprintf(szCmd, sizeof(szCmd), "%s", j_obj.dump().c_str());
CmdProc(szCmd);
}